package com.dk.util;

import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.FileNotFoundException;
import java.net.URL;

/**
 * 路径工具
 *
 * @author: A11181121050450
 * @date: 2020-05-21 16:04
 */
public class PathUtil {
    public static String getRootDir() throws FileNotFoundException {
        URL url = ResourceUtils.getURL(ResourceUtils.CLASSPATH_URL_PREFIX);
        if(ResourceUtils.URL_PROTOCOL_JAR.equalsIgnoreCase(url.getProtocol())){
            return ResourceUtils.getFile("").getAbsolutePath();
        }else{
            return new File(url.getFile()).getParentFile().getParentFile().getAbsolutePath();
        }
    }

    public static void main(String[] args) {
        System.out.println(new File(""));
    }
}
